package com.sskj.gcc.market;

import com.lzy.okgo.OkGo;
import com.sskj.gcc.market.data.Stock;
import com.sskj.gocoin.m.HttpConfig;
import com.sskj.gocoin.m.bean.bean.HttpResponse;
import com.sskj.gocoin.m.http.JsonCallBack;
import com.sskj.gocoin.p.base.BasePresenter;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/05/22
 */
class ChartPresenter extends BasePresenter<ChartFragment> {
    /**
     * 获取股票K线
     *
     * @param goodsType K线周期(minute/minute5/minute15/minute30/minute60/day)
     * @param code      (BCH_USDT/ETC_USDT/ETH_USDT/BTC_USDT/LTC_USDT )
     */
    public void getStockInfo( String goodsType, String code) {
        OkGo.<HttpResponse<List<Stock>>>get(HttpConfig.BASE_URL + HttpConfig.GOODS_INFO)
                .params("goodsType", goodsType)
                .params("code", code)
                .execute(new JsonCallBack<HttpResponse<List<Stock>>>(this, false) {
                    @Override
                    public void _onSuccess(com.lzy.okgo.model.Response<HttpResponse<List<Stock>>> response) {
                        if (response.body().getCode()==200) {
                            List<Stock> stockList = response.body().getData();
                            mView.setChartData(stockList);
                        }
                    }
                });
    }
}
